package com.lagou.mapper;

import com.lagou.pojo.Orders;
import com.lagou.pojo.Users;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author srh
 * @date 2020/02/26
 **/
public interface OrdersMapper {

    /**
     * findAll
     *
     * @return
     */
    List<Orders> xmlFindAll();

    /**
     * findAll
     *
     * @return
     */
    @Select("select * from orders")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "orderTime", column = "ordertime"),
            @Result(property = "total", column = "total"),
            @Result(property = "users", column = "uid", javaType = Users.class,
                    one = @One(select = "com.lagou.mapper.UsersMapper.findById")),
    })
    List<Orders> findAll();

    /**
     * 主键查询
     *
     * @param uid
     * @return
     */
    @Select("select * from orders where uid = #{uid}")
    List<Orders> findByUid(Long uid);
}
